// generated 2005/9/11 21:59:16 CST by xihels@163.com
//

#if defined __GNUC__ && __GNUC__ < 3
#error This program will crash if compiled with g++ 2.x
// see the dynamic_cast bug in the gtkmm FAQ
#endif //
#include "config.h"
#include <gtkmmconfig.h>
#if GTKMM_MAJOR_VERSION==2 && GTKMM_MINOR_VERSION>2
#define GMM_GTKMM_22_24(a,b) b
#else //gtkmm 2.2
#define GMM_GTKMM_22_24(a,b) a
#endif //
#include "UserinfoWindow.h"
#include <gdk/gdkkeysyms.h>
#include <gtkmm/accelgroup.h>
#include <gtkmm/radiobutton.h>
#include <string>
#include <stdlib.h>
using std::string;

#include "MainWindow.h"
#include "QQSession.h"
#include "FriendList.h"
#include "pixmaps.h"

#include "QQ.h"

extern CodeConverter g2u;
const gint sex_types_count = 4;
const gchar *sex_types[] = {
    "男", "女", "不男不女", "男女不分",
};
const gint blood_types_count = 5;
const gchar *blood_types[] = {
        "其它", "A", "B", "O", "AB",
};

const gint country_names_count = 6;
const gchar *country_names[] = {
        "中国", "中国香港", "中国澳门", "中国台湾",
        "新加坡", "马来西亚", "美国",
};

const gint province_names_count = 34;
const gchar *province_names[] = {
        "北京", "天津", "上海", "重庆", "香港",
        "河北", "山西", "内蒙古", "辽宁", "吉林",
        "黑龙江", "江西", "浙江", "江苏", "安徽",
        "福建", "山东", "河南", "湖北", "湖南",
        "广东", "广西", "海南", "四川", "贵州",
        "云南", "西藏", "陕西", "甘肃", "宁夏",
        "青海", "新疆", "台湾", "澳门",
};

const gint zodiac_names_count = 13;
const gchar *zodiac_names[] = {
        "-", "鼠", "牛", "虎", "兔",
        "龙", "蛇", "马", "羊", "猴",
        "鸡", "狗", "猪",
};

const gint horoscope_names_count = 13;
const gchar *horoscope_names[] = {
        "-", "水瓶座", "双鱼座", "牡羊座", "金牛座",
        "双子座", "巨蟹座", "狮子座", "处女座", "天秤座",
        "天蝎座", "射手座", "魔羯座",
};

const gint occupation_names_count = 15;
const gchar *occupation_names[] = {
        "全职", "兼职", "制造业", "商业", "失业中",
        "学生", "工程师", "政府部门", "教育业", "服务行业",
        "老板", "计算机业", "退休", "金融业",
        "销售/广告/市场",
};




UserinfoWindow::UserinfoWindow(QQSession& _session, bool _isSelf) :
    Gtk::Window(Gtk::WINDOW_TOPLEVEL),
    session(_session),
    isSelf(_isSelf)
{  
    userinfoWindow = this;
    gmm_data = new GlademmData(get_accel_group());
    entryAge = Gtk::manage(new class Gtk::Entry());
    comboboxSex = Gtk::manage(new class Gtk::ComboBoxEntryText());
    comboboxProvince = Gtk::manage(new class Gtk::ComboBoxEntryText());
    labelUid = Gtk::manage(new class Gtk::Label("_QQ号码", true));
    entryUid = Gtk::manage(new class Gtk::Entry());
    entryNickname = Gtk::manage(new class Gtk::Entry());
    labelNickname = Gtk::manage(new class Gtk::Label("昵称(_N)", true));
    labelAge = Gtk::manage(new class Gtk::Label("年龄(_A)", true));
    labelSex = Gtk::manage(new class Gtk::Label("性别(_E)", true));
    labelCountry = Gtk::manage(new class Gtk::Label("国家/地区(_U)", true));
    labelProvince = Gtk::manage(new class Gtk::Label("省份(_P)", true));
    labelCity = Gtk::manage(new class Gtk::Label("城市(_I)", true));
    entryCity = Gtk::manage(new class Gtk::Entry());
    labelZip_code = Gtk::manage(new class Gtk::Label("邮政编码(_Z)", true));
    entryZip_code = Gtk::manage(new class Gtk::Entry());

    imageFace = getImage("qq.png");

    comboboxCountry = Gtk::manage(new class Gtk::ComboBoxEntryText());
    tableBase = Gtk::manage(new class Gtk::Table(2, 2, false));
    frameBase = Gtk::manage(new class Gtk::Frame());
    labelBase = Gtk::manage(new class Gtk::Label("基本信息(_B)", true));
    labelEmail = Gtk::manage(new class Gtk::Label("电子邮件(_E)", true));
    entryEmail = Gtk::manage(new class Gtk::Entry());
    entryAddress = Gtk::manage(new class Gtk::Entry());
    labelAddress = Gtk::manage(new class Gtk::Label("地址(_A)", true));
    entryPhone = Gtk::manage(new class Gtk::Entry());
    labelPhone = Gtk::manage(new class Gtk::Label("电话(_P)", true));
    labelHomepage = Gtk::manage(new class Gtk::Label("主页(_H)", true));
    entryHomepage = Gtk::manage(new class Gtk::Entry());
    entryMobile = Gtk::manage(new class Gtk::Entry());
    labelMobie = Gtk::manage(new class Gtk::Label("手机(_M)", true));
    tableContact = Gtk::manage(new class Gtk::Table(2, 2, false));
    frameContact = Gtk::manage(new class Gtk::Frame());

    Gtk::RadioButton::Group _RadioBGroup_radiobuttonPublic;
    radiobuttonPublic = Gtk::manage(
	    new class Gtk::RadioButton(_RadioBGroup_radiobuttonPublic,
		"所有人可见(_U)", true));
    radiobuttonFriend = Gtk::manage
	(new class Gtk::RadioButton(_RadioBGroup_radiobuttonPublic,
				    "仅对好友可见(_F)", true));
    radiobuttonPrivate = Gtk::manage(
	    new class Gtk::RadioButton(_RadioBGroup_radiobuttonPublic, 
		"所有人都不可见(_V)", true));
    hboxShowtype = Gtk::manage(new class Gtk::HBox(false, 0));
    labelShowinfo = Gtk::manage(new class Gtk::Label("以上信息"));
    frameShowinfo = Gtk::manage(new class Gtk::Frame());
    vboxContact = Gtk::manage(new class Gtk::VBox(false, 0));
    labelContact = Gtk::manage(new class Gtk::Label("联系方式(_O)", true));
    labelName = Gtk::manage(new class Gtk::Label("姓名(_N)", true));
    entryName = Gtk::manage(new class Gtk::Entry());
    labelZodiac = Gtk::manage(new class Gtk::Label("生肖(_Z)", true));
    comboboxZodiac= Gtk::manage(new class Gtk::ComboBoxText());
    entrySchool = Gtk::manage(new class Gtk::Entry());
    labelBlood = Gtk::manage(new class Gtk::Label("血型(_X)", true));
    comboboxBlood = Gtk::manage(new class Gtk::ComboBoxText());
    comboboxOccupation = Gtk::manage(new class Gtk::ComboBoxEntryText());
    labelHoroscope = Gtk::manage(new class Gtk::Label("星座(_H)", true));
    comboboxHoroscope = Gtk::manage(new class Gtk::ComboBoxText());
    textviewIntro = Gtk::manage(new class Gtk::TextView());
    scrolledwindowIntro = Gtk::manage(new class Gtk::ScrolledWindow());
    labelSchool = Gtk::manage(new class Gtk::Label("学校(_L)", true));
    labelOccupation = Gtk::manage(new class Gtk::Label("职业(_U)", true));
    labelIntro = Gtk::manage(new class Gtk::Label("介绍(_I)", true));
    tableDetails = Gtk::manage(new class Gtk::Table(2, 2, false));
    frameDetails = Gtk::manage(new class Gtk::Frame());
    labelDetails = Gtk::manage(new class Gtk::Label("细节(_D)", true));
    labelOldPasswd = Gtk::manage(new class Gtk::Label("旧密码(_L)", true));
    entryOldPasswd = Gtk::manage(new class Gtk::Entry());
    checkbuttonModify = Gtk::manage(new class Gtk::CheckButton("修改(_F)", true));
    entryNewPasswd = Gtk::manage(new class Gtk::Entry());
    labelNewPassed = Gtk::manage(new class Gtk::Label("新密码(_N)", true));
    labelRetellPasswd = Gtk::manage(new class Gtk::Label("确认(_E)", true));
    entryRetell = Gtk::manage(new class Gtk::Entry());
    tablePasswd = Gtk::manage(new class Gtk::Table(2, 2, false));
    labelPasswd = Gtk::manage(new class Gtk::Label("更改密码"));
    framePasswd = Gtk::manage(new class Gtk::Frame());

    Gtk::RadioButton::Group _RadioBGroup_radiobuttonAny;
    radiobuttonAny = Gtk::manage(
	    new class Gtk::RadioButton(_RadioBGroup_radiobuttonAny,
		"任何人都可加我(_A)", true));
    radiobuttonAuth = Gtk::manage(
	    new class Gtk::RadioButton(_RadioBGroup_radiobuttonAny, 
		"需要认证才可加我(_U)", true));
    radiobuttonNo = Gtk::manage(
	    new class Gtk::RadioButton(_RadioBGroup_radiobuttonAny,
		"任何人都不可以加我(_T)", true));
    vboxAuthType = Gtk::manage(new class Gtk::VBox(false, 0));
    labelAuthType = Gtk::manage(new class Gtk::Label("认证类型"));
    frameAuthType = Gtk::manage(new class Gtk::Frame());
    vboxSecurity = Gtk::manage(new class Gtk::VBox(false, 0));
    labelSecurity = Gtk::manage(new class Gtk::Label("安全设置(_S)", true));
    notebook1 = Gtk::manage(new class Gtk::Notebook());
    buttonModify = Gtk::manage(new class Gtk::Button("修改(_M)", true));
    buttonClose = Gtk::manage(new class Gtk::Button("关闭(_C)", true));
    hbuttonbox1 = Gtk::manage(new class Gtk::HButtonBox(Gtk::BUTTONBOX_END, 5));

    vbox1 = Gtk::manage(new class Gtk::VBox(false, 0));

    labelUid->set_alignment(0,0.5);
    labelUid->set_mnemonic_widget(*entryUid);
    labelNickname->set_alignment(0,0.5);
    labelNickname->set_mnemonic_widget(*entryNickname);
    labelAge->set_alignment(0,0.5);
    labelAge->set_mnemonic_widget(*entryAge);
    labelSex->set_alignment(0,0.5);
    labelSex->set_mnemonic_widget(*comboboxSex);
    labelCountry->set_alignment(0,0.5);
    labelCountry->set_mnemonic_widget(*comboboxCountry);
    labelProvince->set_alignment(0,0.5);
    labelProvince->set_mnemonic_widget(*comboboxProvince);
    labelCity->set_alignment(0,0.5);
    labelCity->set_mnemonic_widget(*entryCity);
    labelZip_code->set_alignment(0,0.5);
    labelZip_code->set_mnemonic_widget(*entryZip_code);
    entryZip_code->set_activates_default(false);
    imageFace->set_padding(20,0);
    
    tableBase->set_border_width(10);
    tableBase->attach(*entryAge,
	    1, 2, 2, 3,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*comboboxSex,
	    1, 2, 3, 4, Gtk::FILL, Gtk::FILL, 0, 0);
    tableBase->attach(*comboboxProvince,
	    1, 2, 5, 6, Gtk::FILL, Gtk::FILL, 0, 0);
    tableBase->attach(*labelUid, 0, 1, 0, 1,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*entryUid, 1, 2, 0, 1,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*entryNickname, 1, 2, 1, 2,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*labelNickname, 0, 1, 1, 2,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*labelAge, 0, 1, 2, 3,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*labelSex, 0, 1, 3, 4,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*labelCountry, 0, 1, 4, 5,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*labelProvince, 0, 1, 5, 6,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*labelCity, 0, 1, 6, 7, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*entryCity, 1, 2, 6, 7, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*labelZip_code, 0, 1, 7, 8,
	    Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*entryZip_code, 1, 2, 7, 8,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableBase->attach(*imageFace, 2, 3, 0, 8,
	    Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
    tableBase->attach(*comboboxCountry, 1, 2, 4, 5,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    frameBase->set_border_width(10);
    frameBase->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
    frameBase->add(*tableBase);
    labelEmail->set_alignment(0,0.5);
    labelEmail->set_mnemonic_widget(*entryEmail);
    labelAddress->set_alignment(0,0.5);
    labelAddress->set_mnemonic_widget(*entryAddress);
    labelPhone->set_alignment(0,0.5);
    labelPhone->set_mnemonic_widget(*entryPhone);
    labelHomepage->set_alignment(0,0.5);
    labelHomepage->set_mnemonic_widget(*entryHomepage);
    labelMobie->set_alignment(0,0.5);
    labelMobie->set_mnemonic_widget(*entryMobile);

    tableContact->set_border_width(10);
    tableContact->attach(*labelEmail, 0, 1, 0, 1,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableContact->attach(*entryEmail, 1, 2, 0, 1,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableContact->attach(*entryAddress, 1, 2, 1, 2, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableContact->attach(*labelAddress, 0, 1, 1, 2, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableContact->attach(*entryPhone, 1, 2, 2, 3, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableContact->attach(*labelPhone, 0, 1, 2, 3, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableContact->attach(*labelHomepage, 0, 1, 4, 5,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableContact->attach(*entryHomepage, 1, 2, 4, 5, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableContact->attach(*entryMobile, 1, 2, 3, 4,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableContact->attach(*labelMobie, 0, 1, 3, 4, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    frameContact->set_border_width(10);
    frameContact->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
    frameContact->add(*tableContact);

    hboxShowtype->set_border_width(3);
    hboxShowtype->pack_start(*radiobuttonPublic);
    hboxShowtype->pack_start(*radiobuttonFriend);
    hboxShowtype->pack_start(*radiobuttonPrivate);
    
    frameShowinfo->set_border_width(10);
    frameShowinfo->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
    frameShowinfo->set_label_align(0,0.5);
    frameShowinfo->add(*hboxShowtype);
    frameShowinfo->set_label_widget(*labelShowinfo);

    vboxContact->pack_start(*frameContact);
    vboxContact->pack_start(*frameShowinfo);
    labelName->set_alignment(0,0.5);
    labelName->set_mnemonic_widget(*entryName);
    entryName->set_size_request(100,-1);
    labelZodiac->set_alignment(0,0.5);
    labelZodiac->set_mnemonic_widget(*comboboxZodiac);
    comboboxZodiac->set_size_request(80,-1);
    labelBlood->set_alignment(0,0.5);
    labelBlood->set_mnemonic_widget(*comboboxBlood);
    comboboxBlood->set_size_request(80,-1);
    labelHoroscope->set_alignment(0,0.5);
    labelHoroscope->set_mnemonic_widget(*comboboxHoroscope);
    comboboxHoroscope->set_size_request(80,-1);
    
    textviewIntro->set_wrap_mode(Gtk::WRAP_WORD);

    scrolledwindowIntro->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
    scrolledwindowIntro->set_shadow_type(Gtk::SHADOW_IN);
    scrolledwindowIntro->add(*textviewIntro);
    
    labelSchool->set_alignment(0,0.5);
    labelSchool->set_mnemonic_widget(*entrySchool);
    labelOccupation->set_alignment(0,0.5);
    labelOccupation->set_mnemonic_widget(*comboboxOccupation);
    labelIntro->set_alignment(0,0.5);
    labelIntro->set_mnemonic_widget(*textviewIntro);

    tableDetails->set_border_width(10);
    tableDetails->attach(*labelName, 0, 1, 0, 1,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableDetails->attach(*entryName, 1, 2, 0, 1, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableDetails->attach(*labelZodiac, 2, 3, 0, 1,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableDetails->attach(*comboboxZodiac, 3, 4, 0, 1,
	    Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
    tableDetails->attach(*entrySchool, 1, 2, 1, 2, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableDetails->attach(*labelBlood, 2, 3, 1, 2,
	    Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableDetails->attach(*comboboxBlood, 3, 4, 1, 2,
	    Gtk::FILL, Gtk::FILL, 0, 0);
    tableDetails->attach(*comboboxOccupation, 1, 2, 2, 3,
	    Gtk::FILL, Gtk::FILL, 0, 0);
    tableDetails->attach(*labelHoroscope, 2, 3, 2, 3,
	    Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableDetails->attach(*comboboxHoroscope, 3, 4, 2, 3,
	    Gtk::FILL, Gtk::FILL, 0, 0);
    tableDetails->attach(*scrolledwindowIntro, 1, 4, 3, 4,
	    Gtk::FILL, Gtk::FILL, 0, 0);
    tableDetails->attach(*labelSchool, 0, 1, 1, 2,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableDetails->attach(*labelOccupation, 0, 1, 2, 3,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tableDetails->attach(*labelIntro, 0, 1, 3, 4,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    frameDetails->set_border_width(10);
    frameDetails->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
    frameDetails->set_label_align(0,0.5);
    frameDetails->add(*tableDetails);
    labelOldPasswd->set_alignment(0,0.5);
    labelOldPasswd->set_mnemonic_widget(*entryOldPasswd);

    entryNewPasswd->set_visibility(false);
    labelNewPassed->set_alignment(0,0.5);
    labelNewPassed->set_mnemonic_widget(*entryNewPasswd);
    labelRetellPasswd->set_alignment(0,0.5);
    labelRetellPasswd->set_mnemonic_widget(*entryRetell);
    entryRetell->set_visibility(false);

    tablePasswd->set_border_width(10);
    tablePasswd->attach(*labelOldPasswd, 0, 1, 0, 1,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tablePasswd->attach(*entryOldPasswd, 1, 2, 0, 1,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tablePasswd->attach(*checkbuttonModify, 2, 3, 0, 1, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tablePasswd->attach(*entryNewPasswd, 1, 2, 1, 2,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tablePasswd->attach(*labelNewPassed, 0, 1, 1, 2,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tablePasswd->attach(*labelRetellPasswd, 0, 1, 2, 3,
	    Gtk::FILL, Gtk::AttachOptions(), 0, 0);
    tablePasswd->attach(*entryRetell, 1, 2, 2, 3,
	    Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions(), 0, 0);

    framePasswd->set_border_width(10);
    framePasswd->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
    framePasswd->set_label_align(0,0.5);
    framePasswd->add(*tablePasswd);
    framePasswd->set_label_widget(*labelPasswd);

    vboxAuthType->set_border_width(10);
    vboxAuthType->pack_start(*radiobuttonAny, Gtk::PACK_SHRINK, 0);
    vboxAuthType->pack_start(*radiobuttonAuth, Gtk::PACK_SHRINK, 0);
    vboxAuthType->pack_start(*radiobuttonNo, Gtk::PACK_SHRINK, 0);

    frameAuthType->set_border_width(10);
    frameAuthType->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
    frameAuthType->set_label_align(0,0.5);
    frameAuthType->add(*vboxAuthType);
    frameAuthType->set_label_widget(*labelAuthType);
    
    vboxSecurity->pack_start(*framePasswd);
    vboxSecurity->pack_start(*frameAuthType);
    
    notebook1->set_flags(Gtk::CAN_FOCUS);
    notebook1->set_show_tabs(true);
    notebook1->set_show_border(true);
    notebook1->set_tab_pos(Gtk::POS_TOP);
    notebook1->set_scrollable(true);
    notebook1->append_page(*frameBase, *labelBase);
    notebook1->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
    notebook1->append_page(*vboxContact, *labelContact);
    notebook1->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
    notebook1->append_page(*frameDetails, *labelDetails);
    notebook1->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
    if (isSelf)
	notebook1->append_page(*vboxSecurity, *labelSecurity);
    notebook1->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);

    hbuttonbox1->set_border_width(5);
    hbuttonbox1->pack_start(*buttonModify);
    hbuttonbox1->pack_start(*buttonClose);
    vbox1->pack_start(*notebook1);
    vbox1->pack_start(*hbuttonbox1);

    if (isSelf)
	userinfoWindow->set_title("本人信息");
    else
	userinfoWindow->set_title("好友信息");

    userinfoWindow->property_window_position().set_value(Gtk::WIN_POS_CENTER_ALWAYS);
    userinfoWindow->set_resizable(false);
    userinfoWindow->property_destroy_with_parent().set_value(false);
    userinfoWindow->add(*vbox1);

    for (int i = 0; i < country_names_count; i++)
	comboboxCountry->append_text(country_names[i]);

    for (int i = 0; i < sex_types_count; i++)
	comboboxSex->append_text(sex_types[i]);

    for (int i = 0; i < blood_types_count; i++)
	comboboxBlood->append_text(blood_types[i]);

    for (int i = 0; i < province_names_count; i++)
	comboboxProvince->append_text(province_names[i]);

    for (int i = 0; i < zodiac_names_count; i++)
	comboboxZodiac->append_text(zodiac_names[i]);

    for (int i = 0; i < horoscope_names_count; i++)
	comboboxHoroscope->append_text(horoscope_names[i]);

    for (int i = 0; i < occupation_names_count; i++)
	comboboxOccupation->append_text(occupation_names[i]);

    if (!isSelf) {
	entryAge->set_editable(false);
	comboboxSex->set_sensitive(false);
	comboboxProvince->set_sensitive(false);
	entryUid->set_editable(false);
	entryNickname->set_editable(false);
	entryCity->set_editable(false);
	entryZip_code->set_editable(false);
	comboboxCountry->set_sensitive(false);
	entryEmail->set_editable(false);
	entryAddress->set_editable(false);
	entryPhone->set_editable(false);
	entryHomepage->set_editable(false);
	entryMobile->set_editable(false);

	hboxShowtype->set_sensitive(false);
	entryName->set_editable(false);

	entrySchool->set_editable(false);
	comboboxOccupation->set_sensitive(false);
	comboboxBlood->set_sensitive(false);
	comboboxZodiac->set_sensitive(false);
	comboboxHoroscope->set_sensitive(false);
	textviewIntro->set_editable(false);

	buttonModify->set_sensitive(false);

    }

    userinfoWindow->show_all();

    buttonClose->add_accelerator("clicked",
	   gmm_data->getAccelGroup(), GDK_Escape, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE);

    buttonClose->signal_clicked().connect(
		sigc::mem_fun(*this, &UserinfoWindow::on_buttonClose_clicked), false);

}

bool UserinfoWindow::on_delete_event(GdkEventAny *)
{
    delete this;
    return false;
}

void UserinfoWindow::on_buttonClose_clicked()
{
    delete this;
}

UserinfoWindow::~UserinfoWindow()
{  
    delete gmm_data;
}


#define GET_STRING_LEN(A) infos[(A) + 1] - infos[(A)] - 1


void UserinfoWindow::refreshInfo(const GetUserInfoReplyPacket& packet)
{
    const QQContact* contact = packet.getContact();
    if (NULL == connect)
	return ;

    int len;
    const char* const * infos = contact->infos;
    entryUid->set_text(infos[0]);

    len = GET_STRING_LEN(1);
    entryNickname->set_text(g2u.convert(infos[1], len));

    len = GET_STRING_LEN(2);
    comboboxCountry->set_active_text(g2u.convert(infos[2], len));

    len = GET_STRING_LEN(3);
    comboboxProvince->set_active_text(g2u.convert(infos[3], len));


    entryZip_code->set_text(infos[4]);

    len = GET_STRING_LEN(5);
    entryAddress->set_text(g2u.convert(infos[5], len));

    entryPhone->set_text(infos[6]);

    entryAge->set_text(infos[7]);

    len = GET_STRING_LEN(8);
    comboboxSex->set_active_text(g2u.convert(infos[8], len));

    len = GET_STRING_LEN(9);
    entryName->set_text(g2u.convert(infos[9], len));

    entryEmail->set_text(infos[10]);

    len = GET_STRING_LEN(16);
    comboboxOccupation->set_active_text(g2u.convert(infos[16], len));

    entryHomepage->set_text(infos[17]);

    //
    //printf("认证类型 = %s\n", infos[18]);
    switch (*infos[18] - '\0')
    {
	case 0:
	    radiobuttonAny->set_active(true);
	    break;
	case 1:
	    radiobuttonAuth->set_active(true);
	    break;
	case 2:
	    radiobuttonNo->set_active(true);
	    break;
    }

    /**
     * 1. QQ号
     * 2. 昵称
     * 3. 国家
     * 4. 省
     * 5. 邮政编码
     * 6. 地址
     * 7. 电话
     * 8. 年龄
     * 9. 性别
     * 10. 姓名
     * 11. Email
     * 12. 寻呼机sn，（sn是什么玩意，我也不知道）
     * 13. 寻呼机号
     * 14. 寻呼机服务提供商
     * 15. 寻呼机base num（也不清楚这是什么）
     * 16. 寻呼机类型
     * 17. 职业
     * 18. 主页
     * 19. 认证类型（应该是被人加自己为好友的时候的认证类型把）
     * 20. unknown 1
     * 21. unknown 2
     * 22. 头像，头像是用一个数代表的，比如27, 因为QQ目录下的头像是从1开始编号的，
     *     但是这个头像的数字却是从0开始计数的。并且注意，QQ的目录下面每种头像都
     *     有3个bmp，所以按数字这么一排，27应该是10-1.bmp
     * 23. 手机号
     * 24. 手机类型 
     * 25. 介绍
     * 26. 城市
     * 27. unknown 3
     * 28. unknown 4
     * 29. unknown 5
     * 30. is_open_hp
     * 31. is_open_contact（通讯方式是否对其他人可见）
     * 32. 学校
     * 33. 星座
     * 34. 生肖
     * 35. 血型
     * 36. QQ秀
     * 37. unknown 6，总是0x2D
     */

    // 
    //printf("头像 = %s\n", infos[21]);

    int index = atoi(infos[21]);
    imageFace->set(getPix(index / 3, QQ_FRIEND_STATUS_ONLINE));


    entryMobile->set_text(infos[22]);

    //
    //printf("手机类型 = %s\n", infos[23]);


    Glib::RefPtr<Gtk::TextBuffer> buffer = textviewIntro->get_buffer();
    Gtk::TextBuffer::iterator end = buffer->insert(buffer->end(),g2u.convert(infos[24])); 

    len = GET_STRING_LEN(25);
    entryCity->set_text(g2u.convert(infos[25], len));

    //
    //printf("通讯方式是否对其他人可见 = %s\n", infos[30]);

    switch (*infos[30]) {
	case 0:
	    radiobuttonPublic->set_active(true);
	    break;
	case 1:
	    radiobuttonFriend->set_active(true);
	    break;
	case 2:
	    radiobuttonPrivate->set_active(true);
	    break;

    }

    len = GET_STRING_LEN(31);
    entrySchool->set_text(g2u.convert(infos[31], len));

    index = atoi(infos[32]);
    comboboxHoroscope->set_active(index);

    len = atoi(infos[33]);
    comboboxZodiac->set_active(index);


    len = atoi(infos[34]);
    comboboxBlood->set_active(index);

    //
    // printf("QQ秀 = %s\n", infos[35]);

}

